package com.example.emailsender;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.widget.Toast;

public class EmailSender extends Activity {
	
	Context context;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_email_sender);
        Mail m = new Mail("androiddemo926@gmail.com", "android123456");
        
        String[] toArr = {"kaustubhmalgaonkar@gmail.com","swapnilpw01@gmail.com","rajeshpatil0707@gmail.com"}; // This is an array, you can add more emails, just separate them with a coma
		m.setTo(toArr); // load array to setTo function
		m.setFrom("androiddemo926@gmail.com"); // who is sending the email
		m.setSubject("Test Contact");
		m.setBody("Backup Mail"); 
 
		try {
			Toast.makeText(EmailSender.this, "Start", Toast.LENGTH_LONG).show();
			m.addAttachment("/sdcard/test.xml");  // path to file you want to attach
			if(m.send()) {
				// success
				Toast.makeText(EmailSender.this, "Email was sent successfully.", Toast.LENGTH_LONG).show();
			} else {
				// failure
				Toast.makeText(EmailSender.this, "Email was not sent.", Toast.LENGTH_LONG).show();
			}
		} catch(Exception e) {
			// some other problem
			Toast.makeText(EmailSender.this, "There was a problem sending the email.", Toast.LENGTH_LONG).show();
		} 
    }

    

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_email_sender, menu);
        return true;
    }
}
